<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    =={{msg}}==={{num}} === <input type="text">
    <hr />
    <span>{{msg}}</span>
    <button @click="num++">++</button>

    <li v-for="(item, index) in list" :key="index">{{item}}</li>
  </div>
  <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.14/vue.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
  <script>
    var vm = new Vue({
      el: "#app",
      data: {
        msg: 'hello  vue',
        num: 1,
        list: []
      },

      // 数据创建之前
      beforeCreate () {
        console.log(this.msg, 'beforeCreate')

      },
      //数据创建好了  一般在 created 操作数据
      created () {
        console.log(this.msg, 'created')
        axios('http://hmajax.itheima.net/api/province').then(res => {
          console.log(res)

          this.list = res.data.list
        })
      },
      //渲染完成之前  数据不会解析
      beforeMount () {
        var dom = document.querySelector('span')
        console.log(dom, 'beforeMount')

      },
      //渲染完成之后  数据解析完成 ==== 操作dom 元素 应该在 mounted 里
      mounted () {
        var dom2 = document.querySelector('input')
        dom2.focus() // 表单聚焦
        var dom = document.querySelector('span')
        console.log(dom, 'beforeMount')
      },
      // 数据更新前
      beforeUpdate () {
        console.log('beforeUpdate')

      },
      //数据更新后
      updated () {
        console.log('updated')

      },
    })

    // console.log(vm, 2222);
  </script>
</body>

</html>